
<script src="__LAYUI__/layui.js"></script>
<link href="__LAYUI__/css/layui.css" rel="stylesheet"/>

<table id="table" lay-filter="test"></table>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
</script>



<script>
    layui.use(['table','jquery','layer'], function () {
        var table = layui.table,
            $ = layui.$;
        table.render({
            elem: 'table'
            ,
            id: 'otherTable'
            ,
            height: 300
            ,
            skin: 'line'
            ,
            even: true
            ,
            size: 'lg'
            ,
            shadeClose:false,
            cols: [[
                {field: 'author_id', title: 'ID', width: 120}
                , {field: 'author_name', title: '作者名称', width: 200}
                , {fixed: 'right', width: 160, align: 'center', toolbar: '#barDemo'}
            ]]

            ,response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                ,statusCode: 1 //成功的状态码，默认：0
            }
            ,url:'/index/material/getOthers?level='+{$author_level}+'&book_id='+{$book_id},
        });

        table.on('tool(test)',function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            var tr = obj.tr;

            if(layEvent === 'edit'){
                layer.open({
                    type: 2,
                    offset:'50px',
                    title: data.authorPosition ,
                    scrollbar: false,
                    resize: false,
                    area:['500px','280px'],
                    shadeClose: true,
                    content: ['/index/input/editOthers?author_id=' + data.author_id,'no'],
                    end:function () {
                        location.reload();
                    }
                });
            }
        });
    });
</script>